package io.litchi.auth.application.service;

import io.litchi.auth.domain.entity.auth.User;
import io.litchi.auth.domain.repository.UserRepository;
import jakarta.transaction.Transactional;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Optional;

/**
 *
 *
 * @author 认证相关
 * @since 2025-09-19
 */
@Service
@AllArgsConstructor
public class AuthService {
    private UserRepository userRepository;

    @Transactional
    public void updateLastLoginDateById(Long id) {
        userRepository.updateLastLoginDate(id, LocalDateTime.now());
    }

    public Optional<User> findByUsername(String username, Class<User> userClass) {
        return userRepository.findByUsername(username,userClass);
    }
}